<include file="Public/base"/>
<!-- 栏目新增和编辑页面 -->
  <script type="text/javascript" src="__STATIC__/ztree/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>

<script type="text/javascript">
		//点击x删除图片
		$('.del-img').live('click',function(){
			var liObj = $(this).parents('li');
			//找到父级li里面的地址
			var path = liObj.attr('path');
			var thumb = liObj.attr('thumb');
			alert(222);
			//发异步到服务器删除
			$.ajax({
				type:"post",
				url:$("#hiddenajax").val(),
				data:{path:path,thumb:thumb},
				success:function(data){
					//移除图片
					liObj.remove();
				}
				
			});
		})
		
		
		/*$('.del-img1').live('click',function(){alert($(this).index());
			var liObj = $(this).parents('span');
			//找到父级li里面的地址
			var path = liObj.attr('path');
			//发异步到服务器删除
			$.ajax({
				type:"post",
				url:"{|U:'delImg'}",
				data:{path:path},
				success:function(data){
					//移除图片
					liObj.remove();
				}
			});
		})*/
	</script>

<div class="pd-20">
    <form action="" method="POST" class="form form-horizontal" enctype="multipart/form-data"
          id="editGroupForm">
        <div class="row cl">
            <label for="auth-title" class="form-label col-3">栏目所属分类</label>
							
            <div class="formControls col-5">
				<select id="auth-title" type="text" name="column_pid" class="input-text" value="{$auth_group.title}" 
										required
					                   minlength="0"
				                       maxlength="20">
				    <option value="0"  >
					    <?php echo "新增顶级栏目";?>
					</option>                 
				    <volist name="data" id="vo"  >
				    	
					   <option value="{$vo.column_id}"  >
					    <?php echo str_pad("",$vo['deep']*3, "-",STR_PAD_RIGHT); ?>
					    		{$vo.column_title}
					   </option>
					</volist>
				    
				
				</select>
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-3">栏目名称</label>

            <div class="formControls col-5">
                <textarea class="textarea" name="column_title" maxlength="200">{$dataOne.column_title}</textarea>
            	<input type="hidden" name="column_id" value="{$dataOne.column_id}" />
					
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-3">字体颜色</label>

            <div class="formControls col-5">
               <input type="text" name="app_color_style" value="" />
					
            </div>
            <div class="col-4"></div>
        </div>
        <!--排序默认顶级值为0，二级为1-->
        <input type="hidden" id="check" value="<?php $str = $Think.ADMIN_PATH_NAME.$actions['COLUMNCHECK']['url'];echo U($str,array('key'=>$actions['COLUMNCHECK']['key']))?>"  />
               	
        <script>
        	$(function(){
        		$("#auth-title").change(function(){
        			//alert($(this).val());
        			var id=$(this).val();
        			$("input[name=sort]").remove();
        			//发异步到服务器--进行判断column_pid
        			var html='';
					$.ajax({
						type:"get",
						url:$("#check").val(),
						data:{column_id:id},
						success:function(data){
							//alert(data.top);
								html+='<input type="hidden" name="sort" value="'+data.sort+'" />';
							$("#logo").append(html);
						}
						
					});
        		})
        	})
        </script>
        <!--<div class="row cl">
            <label class="form-label col-3">排序</label>

            <div class="formControls col-5">
               <input type="text" name="sort" value="" />
					
            </div>
            <div class="col-4"></div>
        </div>-->
        
        <div id="logo" class="row cl">
            <label class="form-label col-3">Logo</label>

            <div class="formControls col-5">
               <!--上传开始 start-->
               <div lab="uploadFile">
               	<input type="hidden" id="hiddenajax" value="<?php $str = $Think.ADMIN_PATH_NAME.$actions['COLUMNDELIMG']['url'];echo U($str,array('key'=>$actions['COLUMNDELIMG']['key']))?>"  />
               	<input type="hidden" id="hidden" value="<?php $str = $Think.ADMIN_PATH_NAME.$actions['COLUMNUPLOADIFY']['url'];echo U($str,array('key'=>$actions['COLUMNUPLOADIFY']['key']))?>"  />
               	
	            <input id="file" type="file" multiple="true" name='app_icon_url'>
	            <span>类型: *.jpg,*.png 大小: 2000KB 数量: 1</span>
	            <script type="text/javascript">
	                $(function() {
	                	//alert($("#hidden").val());
	                    $('#file').uploadify({
	                    	'formData'    : {'session_id':'<?php echo session_id();?>'},
	                    	
	                        'fileTypeDesc' : '上传文件',//上传描述
	                        'fileTypeExts' : '*.jpg;*.png',
	                        'swf'      : '__STATIC__/uploadify/uploadify.swf',
	                        'uploader' :$("#hidden").val(),
	                        'buttonText':'选择文件',
	                        'fileSizeLimit' : '2000KB',
	                        'uploadLimit' : 11,//上传文件数
	                        'width':65,
	                        'height':25,
	                        'successTimeout':10,//等待服务器响应时间
	                        'removeTimeout' : 2,//成功显示时间
	                        'onUploadSuccess' : function(file, data, response) {
	                            data=$.parseJSON(data);
	                         // alert(data.thumb);
	                            var imageUrl = data.name?data.url:'__STATIC__/uploadify/uploadify-cancel.png';
	                            //alert(imageUrl);==data.url--http://localhost/yuxiang/uploadify_demo/Upload/Content/15/06/89101435416575.jpg
	                            var li="<li thumb='"+data.thumb+"' path='"+data.savepath+"' url='"+data.url+"'><img src='"+imageUrl+"' style='width:100px;heigth:100px;'/><a href='javascript:;' style='color:red' class='del-img'>X</a>";
	                            //把地址放到隐藏域，这样可以提交到服务器了
	                            /*$.each(data.tu,function(k,v){
	                            	li+="<span><img src='"+v+"' style='width:100px;heigth:100px;'/><a href='javascript:;' style='color:red' class='del-img1'>X</a></span>"
	                            })*/
	                            
	                            li += '<input type="hidden" name="" value="'+data.thumb+'"/>';
	                            li += '<input type="hidden" name="app_icon_url" value="'+data.url+'"/>';
	                            li += '</li>';
	                            $("#uploadList ul").prepend(li);
	                        }
	                    });
	                });
	            </script>
	            <div id="uploadList">
	                <ul>
	 
	                </ul>
	            </div>
	        </div>
               <!--上传结束 end-->
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <div class="col-9 col-offset-3">
                <input class="btn btn-primary radius" type="submit" value="确定">
                <button class="btn btn-warning radius" onclick="history.back(-1);return false;">返 回</button>

            </div>
        </div>
    </form>
</div>
<script type="application/javascript" src="__JS__/Employee/auth.js"></script>
